#"Main" - MBR holds opcode; get next byte; dispatch
#  PC = PC + 1; fetch; goto (MBR)


#Start simulation, with the xilinx libraries and ps resolution
vsim -L UNISIM -L XILINXCORELIB -t ps work.top_level

#RESET WAVE-DISPLAY
restart -force -nowave

#View the wave
view wave

#Set time units
formatTime +bestunits +commas

add wave -noupdate -divider "Instruction: Main"

#Initialize Wave-window
do Init.do

#===============================================================================


#MIR = 0
force -deposit sim:/top_level/mir(35:27) 16#00 
#JMPC
force -deposit sim:/top_level/mir(26) 0 0      
#JAMN
force -deposit sim:/top_level/mir(25) 0 0      
#JAMZ 
force -deposit sim:/top_level/mir(24) 0 0       

#Load MBR register with addess 0xA5 (fictive)
force -deposit sim:/top_level/mbr/content 16#A5

#Load PC register with an initial address we can increment (fictive)
force -deposit sim:/top_level/PC/content 16#3

#Fake some data in the program memmory (Fictive)
force -deposit sim:/top_level/ByteCodeData 16#42

# REGISTER RE - none
 force -deposit sim:/top_level/mir(3:0) 16#FF


run 20ns

#Main1 - BYTECODE

 #Addr - 000000000 (prepare for address from MBR)
 force -deposit sim:/top_level/mir(35:27) 16#00
 #JMPC - 1 (address from MBR)
 force -deposit sim:/top_level/mir(26) 1
 #JAMN - 0 (ignore N-bit)
 force -deposit sim:/top_level/mir(25) 0
 #JAMZ - 0 (ignore Z-bit)
 force -deposit sim:/top_level/mir(24) 0
 
 #ALU - B+1
  force -deposit sim:/top_level/mir(23) 0
  force -deposit sim:/top_level/mir(22) 0
  force -deposit sim:/top_level/mir(21) 1
  force -deposit sim:/top_level/mir(20) 1
  force -deposit sim:/top_level/mir(19) 0
  force -deposit sim:/top_level/mir(18) 1
  force -deposit sim:/top_level/mir(17) 0
  force -deposit sim:/top_level/mir(16) 1

 #REGISTER WE - PC
  force -deposit sim:/top_level/mir(15) 0 
  force -deposit sim:/top_level/mir(14) 0 
  force -deposit sim:/top_level/mir(13) 0 
  force -deposit sim:/top_level/mir(12) 0 
  force -deposit sim:/top_level/mir(11) 0 
  force -deposit sim:/top_level/mir(10) 0 
  force -deposit sim:/top_level/mir(9) 1
  force -deposit sim:/top_level/mir(8) 0 
  force -deposit sim:/top_level/mir(7) 0 

 # MEMORY ACCESS - fetch
 force -deposit sim:/top_level/mir(6) 0
 force -deposit sim:/top_level/mir(5) 0
 force -deposit sim:/top_level/mir(4) 1
 
 # REGISTER RE - PC
 force -deposit sim:/top_level/mir(3:0) 16#1

run 22ns
